const mongoose = require('mongoose')

const adminSchema = new mongoose.Schema({
  username: { type: String },
  password: { 
    type: String, 
    // 为了防止再次打开编辑页面，会对加密后的hash再次加密，尽管没有修改
    select: false,
    set (val) {
      return require('bcrypt').hashSync(val,10)
    }
  }
})

module.exports = mongoose.model('AdminUser', adminSchema)